<?php

namespace app\agent\controller\coupon;

use app\agent\controller\Controller;
use app\model\CouponExtension;

class Url extends Controller
{
    /**
     * 生成推广链接
     */
    public function generate()
    {
        if ($msg = dmjValidate([
            'id' => 'require',
            'scene' => 'require|in:product,brand,cps,coupon'
        ], [], input())) {
            return fail($msg);
        }

        $id = input('id');
        $scene = input('scene');

        $url = (new CouponExtension)->$scene($id);

        if (!$url) return fail();

        return success('', $url);

    }


}